feat: add contacts table and conversation export#64
Open
archeren wants to merge 6 commits intoMartian-Engineering:mainfrom
Open
feat: add contacts table and conversation export#64archeren wants to merge 6 commits intoMartian-Engineering:mainfrom
archeren wants to merge 6 commits intoMartian-Engineering:mainfrom
Conversation
added 6 commits
March 14, 2026 23:13
- Add contacts table (peer_id, peer_name, chat_type) - Add peer_id and channel columns to conversations table - Create ContactStore for managing contacts - Update ConversationStore to support peer_id and channel - Add migration for existing databases This enables tracking who conversations are with, and allows exporting conversations organized by peer and date.
- Add export.ts module with exportConversations function
- Add lcm-export-tool.ts following LCM tool patterns
- Register lcm_export tool in plugin index
- Export format: [channel] time name: message
- Directory structure: dm/{peer}/YYYY-MM/YYYY-MM-DD.md
- Support filters: peerId, chatType, from, to
Usage: lcm_export --outputDir ./exports [--peerId xxx] [--chatType dm|group] [--from YYYY-MM-DD] [--to YYYY-MM-DD]
- Test DM conversation export to correct directory - Test group conversation export - Test peerId filtering - Test handling of missing peer info - Uses in-memory database, no effect on production
- Add --peerId, --channel, --chatType parameters to lcm_grep - Update MessageSearchInput to include peer filters - Update searchFullText, searchLike, searchRegex methods - JOIN with conversations and contacts tables for filtering Usage: lcm_grep --pattern 'hello' --peerId 'user:alice' lcm_grep --pattern 'meeting' --chatType group lcm_grep --pattern 'bug' --channel feishu
- Add updateConversationPeer method to LcmContextEngine - Auto-creates/updates contact when peer info is provided - Updates conversation with peer_id and channel - Add lcm_update_peer tool for manual or automatic peer updates Usage: lcm_update_peer --peerId 'user:alice' --peerName 'Alice' --channel feishu --chatType dm Integration: - OpenClaw can call this when receiving inbound metadata - Can also be called manually to update peer info
- Register message_received hook in LCM plugin - Auto-extract peer info from inbound metadata - DM: peer is sender (user:xxx) - Group: peer is chat/group - Automatically populates contacts table on message receipt This enables automatic contact creation without manual calls to lcm_update_peer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds peer tracking and conversation export functionality to LCM, enabling organized export of conversations by who you talked to.
Features
1. Database Schema
New
contactstable:New columns in
conversationstable:2. ContactStore
New store for managing contacts:
create()— Create or update a contactget()— Get contact by peer_idgetAll()— List all contactsupdate()— Update contact fieldsdelete()— Delete a contact3. lcm_export Tool
Export conversations to markdown files organized by peer and date.
lcm_export --outputDir ./exports lcm_export --peerId "user:ou_xxx" lcm_export --chatType dm lcm_export --from 2026-03-01 --to 2026-03-15Output structure:
Message format:
4. Enhanced lcm_grep
Added peer filters to conversation search:
5. Automatic Peer Extraction
Registered
message_receivedhook to auto-extract peer info from inbound messages:user:xxx)chat:xxx)No manual setup required — contacts are created automatically when messages arrive.
6. lcm_update_peer Tool (Manual Override)
Manually update peer info if needed:
Testing
Use Cases
Breaking Changes
None. The schema additions are additive and backward-compatible.
Migration
Existing LCM databases will be automatically migrated on next startup with the new columns and contacts table.